#!/usr/bin/env python3
# vim:fileencoding=utf-8

import sys
import re
from zhnum import zhnum2int

def trans_zhnum(s):
  return re.sub(r'[一二三四五六七八九零十百千万亿]+', lambda m: '%032d' % zhnum2int(m.group(0)), s)

sys.stdout.writelines(sorted(sys.stdin, key=trans_zhnum))
